<link rel="stylesheet" href="css/spa_guestList/spa_handMgn.css" />
<style>
	.page-content{
		padding: 0px !important;   
	}
</style>
<title data-i18n="手牌管理">手牌管理</title>

<!-- 遮罩层 -->
<div id="pageOverlay" class="hide"></div>
<!-- 等待动画 -->
<div id="loading" class="loading hide">						
	<i class="ace-icon fa fa-spinner fa-spin orange bigger-250"></i>
</div>
<div class="row">
	<div id="pageBox"></div>   
	<div class="no-padding"> 
		   <div class="well well-sm" style="margin-bottom:0px;"> 
			    <div class="clearfix" style="margin-left: 35px;">   
				     <div class="pull-left frontspa-search"> 
				      	  <input autofocus="autofocus" type="text" id="inputValue" name="th" autocomplete="off" data-i18n-placeholder="手牌" class="query-item enter_query" style="height:30px;" placeholder="手牌" /> 
					      <div class="btn-group"> 
					       	<button id="handMgnbtnSearch" class="btn btn-sm btn-info" data-i18n="查找" style="margin-top:-4px;margin-left:20px;"><i class="ace-icon fa fa-search"></i>查找</button> 
					      </div>
					      <div class="btn-group"> 
					       	<button id="btnRefresh" class="btn btn-sm btn-info" data-i18n="刷新" style="margin-top:-4px;margin-left:2px;"><i class="ace-icon fa fa-refresh"></i>刷新</button> 
					      </div>  
				     </div> 
				     <div class="pull-right">
				     		<label class="control-label">类型:</label>  
				     		<select id="handType">
				     			<option value="" selected>全部</option>  
				     		</select> 
<!-- 				    		<label class="control-label">  -->
<!-- 								 <input name="status_radio" value="btnJdh" type="radio" class="ace" checked="checked">  -->
<!-- 								 <span class="lbl" data-i18n="手牌列表"></span>  -->
<!-- 							 </label> -->
<!-- 							 <label class="control-label">  -->
<!-- 								 <input name="status_radio" value="btnJdhDetail" type="radio" class="ace">  -->
<!-- 								 <span class="lbl" data-i18n="销售明细"></span>  -->
<!-- 							 </label>  -->
					      <div class="btn-group"> 
					       	<button id="btnBack" class="btn btn-sm btn-default" data-i18n="返回"> <i class="ace-icon fa fa-undo"></i> 返回</button> 
					      </div> 
				     </div> 
			    </div> 
		   </div> 
	</div>
	<div class="accordion-style1 panel-group handMgnContent">   
		
	</div> 
</div>   
<script type="text/javascript">
	//加载资源文件
	var scripts = [
				   "js/plugin/jquery.jqGrid.js",
				   "assets/js/jqGrid/i18n/grid.locale-cn.js",
				   'js/plugin/jsonsql.js',
				   "assets/js/jquery.hotkeys.js",
				   "assets/js/x-editable/bootstrap-editable.js",
				   "js/openSpa/jquery.handMgn.js"
				   ]; 
	//全窗口变量
	var ins_argjson={};
	$(".page-content-area").ace_ajax("loadScripts",scripts,function(){
		$("input[name='th']").focus(); 
		//初始化插件
		$(".handMgnContent").handMgn({
			onSelTh:{"th":sysGetQueryString("th")?sysGetQueryString("th"):""},
			resetBack:function(){
				$("input[name='th']").val("");  
				$("input[name='th']").focus();
			}
		});
		
		//页面初始化
		init();
		
		//事件绑定
		bindEvent(); 
		
	
	});
	
	//初始化
	function init(){
		//手牌类型
		var ds = $.parseJSON(localStorage.getItem("hodict"));
		var filter = "select * from json where (grou_name=='餐位类型')"; 
		var handType = jsonsql.query( filter,ds);
		$(handType).each(function(k,v){
			var html='<option value="'+v.code+'">'+v.descript1+'</option> '; 
			$("#handType").append(html);
		});
	}
	
	//交互
	function interactive(params){
		if(typeof(params)=="undefined")
			params={};
		params=$.extend({},{"operation":"查询","cwlx":$("#handType").val()},params); 
		$.handMgn.getData(params);   
	}
	
	//事件
	function bindEvent(){
		//类型
		$("#handType").bind("change",function(){ 
			interactive();
		});
		
		//视图
// 		$("input[name='status_radio']").bind("click",function(){
// 			interactive({"status_radio":$(this).attr("value")});  
// 	    });
		
		//查询按钮
		$("#handMgnbtnSearch").click(function(){
			var th=$("input[name='th']").val();
			if(th==="")
				interactive();
			else
				interactive({"th":th,"floor":""}); 
		})
		
		//返回按钮
		$("#btnBack").click(function(){
			history.go(-1);
		})
		
		//回车事件
		$("#inputValue").keydown(function(e){ 
			if(e.keyCode==13){
				$("#handMgnbtnSearch").trigger("click");
			}
		});
		
		//刷新
		$("#btnRefresh").bind("click",function(){
			interactive({"operation":"刷新"}); 
		});
		
		//客房状态
		$("body,input[name='th']").bind('keydown', 'Alt+t', function (evt){
			$("#btnRefresh").trigger("click");
			return false;
		});
	}

	//交互等待
	function wait(){
		$("#pageOverlay").removeClass("hide");
		$("#loading").removeClass("hide");
	}
	
	//交互结束
	function goon(){
		$("#pageOverlay").addClass("hide");
		$("#loading").addClass("hide");
	}
	
	//欸一标识
	function getUUID() {
	    var d = new Date().getTime();
	    if (window.performance && typeof window.performance.now === "function") {
	        d += performance.now();
	    }
	    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
	        var r = (d + Math.random() * 16) % 16 | 0;
	        d = Math.floor(d / 16);
	        return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
	    });
	    return uuid;
	}
</script>